<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8" />
    <title>统一地图平台</title><link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
    <style>
        html,
        body,
        #mapui {
            width: 100%;
            height: 100%;
        }

        html,
        body {
            margin: 0;
            padding: 0;
        }
    </style>
</head>

<body>
    <div id="mapui"></div>
    <button type="button" onclick="add()" style="position: absolute;top: 10px;right: 10px;">添加</button>
    <button type="button" onclick="remove()" style="position: absolute;top: 40px;right: 10px;">删除</button>

    <script src="./js_example/script/map.min.js"></script>
    <script src="./js_example/script/demo.js"></script>

    <script>
        var amap = null;
        var marker = null;
        map.Factory.create('mapui', {
            style: style,
            center: center,
            zoom: 11,
            strategy: ['mapboxgl', 'openlayers', 'leaflet'],
            fullExtent: {
                xmin: 108.23365,
                ymin: 17.95253,
                xmax: 111.78395,
                ymax: 20.13104
            }
        }, (o) => {
            amap = o;
        });

        function add() {
            var markerManage = map.Factory.MarkerManage();

            var el = document.createElement('div');

            var iconEl = document.createElement('div');
            iconEl.className = 'custom_marker';
            iconEl.style.backgroundImage = "url('./js_example/images/custom.png')";
            iconEl.style.backgroundSize = 'cover';
            iconEl.style.width = '64px';
            iconEl.style.height = '64px';
            iconEl.style.borderRadius = '50%';
            iconEl.style.cursor = 'pointer';
            iconEl.style.float = "left";
            iconEl.style.verticalAlign = "bottom";

            el.appendChild(iconEl);

            var textEl = document.createElement('div');
            textEl.innerHTML = '文字图片标注';
            textEl.style.fontSize = "14px";
            textEl.style.fontWeight = "bold";
            textEl.style.cursor = 'pointer';
            textEl.style.borderRadius = "30px"
            textEl.style.color = "#70455D";
            textEl.style.textAlign = "center";
            textEl.style.border = "2px solid #EABC56 ";
            textEl.style.backgroundColor = "#FFFFFFFF";
            textEl.style.letterSpacing = "2px";
            textEl.style.padding = "3px 5px 3px 5px";
            textEl.style.float = "right";
            textEl.style.marginLeft = "-15px";
            textEl.style.marginTop = "30px";
            textEl.style.verticalAlign = "bottom";

            el.appendChild(textEl);

            marker = markerManage.add('1', [110.32343, 19.99401], {
                element: el,
                anchor: 'bottom',
                offset: [0, 0]
            });
        }

        function remove() {
            marker.remove();
        }
    </script>
</body>

</html>